home *** CD-ROM | disk | FTP | other *** search
JavaScript | 2000-09-06 | 8.6 KB | 307 lines | [TEXT/dosa] |
- /// Section Begin - CCSSP DHTM (JavaScript 1.2)
- // eHelpÆ Corporation Dynamic HTML JavaScript
- // Copyright© 1998-2000 eHelpÆ Corporation.All rights reserved.
- // Version=4.42
-
- // Warning:Do not modify this file.It is generated by RoboHELPÆ and changes will be overwritten.
-
-
-
- //Begin JavaScript libary for cross-platform positioning object.
- function CCSSP(){} // constructor of CCSSP class
-
- CCSSP.strAgent = navigator.userAgent.toLowerCase();
- CCSSP.nAppVersion = parseInt(navigator.appVersion);
-
- CCSSP.bIsWinOS = ((CCSSP.strAgent.indexOf("win") >= 0) || (CCSSP.strAgent.indexOf("16bit") >= 0));
- CCSSP.bIsMacOS = (CCSSP.strAgent.indexOf("mac") >= 0);
-
- CCSSP.bIsIE = (navigator.appName.indexOf("Microsoft") >= 0);
- CCSSP.bIsIE4 = (CCSSP.bIsIE && (CCSSP.nAppVersion >= 4));
- CCSSP.bIsIE5 = (CCSSP.bIsIE4 && (CCSSP.strAgent.indexOf("msie 5") != -1) )
-
- CCSSP.bIsNav = (navigator.appName.indexOf("Netscape") >= 0);
- CCSSP.bIsNav4 = (CCSSP.bIsNav && (CCSSP.nAppVersion >= 4));
-
- CCSSP.GetObject = function( obj )
- {//convert object name string or reference into a valid object reference
- if( typeof(obj) == "object" )
- return obj;
- else if( typeof(obj) == "string" && obj != "")
- {
- if( CCSSP.bIsNav4 )
- return eval("document." + obj);
- else
- return eval("document.all." + obj);
- }
- else
- return null;
- }
-
- CCSSP.MoveObjectTo = function(obj, x, y)
- {//positioning an object at a specific pixel coordinate
- if( CCSSP.bIsNav4 )
- obj.moveTo(x,y);
- else
- {
- obj.style.pixelLeft = x;
- obj.style.pixelTop = y;
- }
- }
-
- CCSSP.MoveObjectBy = function(obj, dx, dy)
- {//moveing a object by x and/or y pixel
- if( CCSSP.bIsNav4 )
- obj.moveBy(dx,dy);
- else
- {
- obj.style.pixelLeft += dx;
- obj.style.pixelTop += dy;
- }
- }
-
- CCSSP.SetObjectBGColor = function(obj, color)
- {//set the background color of an object
- if( CCSSP.bIsNav4 )
- obj.bgColor = color;
- else
- obj.style.backgroundColor = color;
- }
-
- CCSSP.ShowObject = function(obj, bShow)
- {// set the object to be visible or invisible
- if( CCSSP.bIsNav4 )
- obj.visibility = (bShow == true) ? 'show' : 'hide';
- else
- obj.style.visibility = (bShow == true) ? 'visible' : 'hidden';// when hidden, it still occupy some space.
- }
-
- CCSSP.GetObjectLeft = function(obj)
- {// retrieve the x coordinate of a posionable object
- if( CCSSP.bIsNav4 )
- return obj.left;
- else
- return obj.style.pixelLeft;
- }
-
- CCSSP.GetObjectTop = function(obj)
- {// retrieve the y coordinate of a posionable object
- if( CCSSP.bIsNav4 )
- return obj.top;
- else
- return obj.style.pixelTop;
- }
-
- CCSSP.GetObjectContainLeft = function(obj)
- {// retrieve the x coordinate of a posionable object relative to it's parent element
- if( CCSSP.bIsNav4 )
- return obj.pageX;
- else
- {
- if( obj == document.body )
- return obj.clientLeft;
- else
- return obj.offsetLeft;
- }
- }
-
- CCSSP.GetObjectWindowLeft = function(obj)
- {// retrieve the x coordinate of a posionable object relative to browser window
- if( CCSSP.bIsNav4 )
- return obj.pageX;
- else
- {
- var nOffsetWindowLeft = 0;
- for(var element = obj; element; element = element.offsetParent)
- nOffsetWindowLeft += CCSSP.GetObjectContainLeft(element);
- return nOffsetWindowLeft;
- }
- }
-
- CCSSP.GetObjectContainTop = function(obj)
- {// retrieve the y coordinate of a posionable object relative to it's parent element
- if( CCSSP.bIsNav4 )
- return obj.pageY;
- else
- {
- if( obj == document.body )
- return obj.clientTop;
- else
- return obj.offsetTop;
- }
- }
-
- CCSSP.GetObjectWindowTop = function(obj)
- {// retrieve the y coordinate of a posionable object relative to browser window
- if( CCSSP.bIsNav4 )
- return obj.pageY;
- else
- {
- var nOffsetWindowTop = 0;
- for(var element = obj; element; element = element.offsetParent)
- nOffsetWindowTop += CCSSP.GetObjectContainTop(element);
- return nOffsetWindowTop;
- }
- }
-
- CCSSP.GetObjectHeight = function(obj)
- {// retrieve the height of a posionable object
- if( CCSSP.bIsNav4 )
- return obj.clip.height;
- else
- return obj.offsetHeight;
- }
-
- CCSSP.GetObjectWidth = function(obj)
- {// retrieve the width of a posionable object
- if( CCSSP.bIsNav4 )
- return obj.clip.width;
- else
- return obj.offsetWidth;
- }
-
- CCSSP.RegisterEventHandler = function( srcObj, rawEventName, funcHandler )
- { // to add the "funcHandler" as the "rawEventName" 's handler to the "srcObj" object,the original event handler will be combined
- var oldHandler = "";
- var oldInlineHandler = srcObj[rawEventName.toLowerCase()];
- if( oldInlineHandler != null )
- {
- var functionDefinition = oldInlineHandler.toString();
- var bodyStart = functionDefinition.indexOf( "{" );
- var bodyEnd = functionDefinition.lastIndexOf( "}" );
- if( bodyStart > 0 || bodyEnd > bodyStart )
- oldHandler = functionDefinition.substr( bodyStart + 1, bodyEnd - bodyStart - 2 );
- }
- else if( CCSSP.bIsIE4 )
- { //search for <SCRIPT> tag which define the event handler
- for( var i = 0; i < document.scripts.length; i++ )
- {
- var script = document.scripts[i];
- if( (script.htmlFor == srcObj.id || script.htmlFor == srcObj ) && script.event == rawEventName )
- {
- oldHandler = script.innerHTML;
- break;
- }
- }
- }
-
- if( oldHandler.indexOf(funcHandler) >= 0 )
- return;// to prevent register the funtion twice.
-
- if( CCSSP.bIsNav4 ) // only "onload, onresize, onfocus" apply to window
- {// other raw events will apply to layer
- var noOn = rawEventName.substring(2, rawEventName.length);
- if( typeof(noOn) == "string" && noOn.length > 3 )
- srcObj.captureEvents( Event[noOn.toUpperCase()] );
- }
-
- var newHandler = oldHandler;
- if( newHandler.length == 0 )
- newHandler = funcHandler;
- else
- newHandler += "; " + funcHandler;
- srcObj[rawEventName.toLowerCase()] = new Function( newHandler );
- }
-
- CCSSP.GetWindowHeight = function()
- {// retrieve the height of available content in browser window
- if( CCSSP.bIsNav4 )
- return window.innerHeight;
- else
- return document.body.clientHeight;
- }
-
- CCSSP.GetWindowBottom = function()
- {// retrieve the bottom postion of browser window
- if( CCSSP.bIsNav4 )
- return window.outerHeight + window.pageYOffset;
- else
- return document.body.clientHeight + document.body.scrollTop;
- }
-
- CCSSP.GetWindowWidth = function()
- {// retrieve the width of available content in browser window
- if( CCSSP.bIsNav4 )
- return window.innerWidth;
- else
- return document.body.clientWidth;
- }
-
- CCSSP.GetWindowRight = function()
- {// retrieve the right postion of browser window
- if( CCSSP.bIsNav4 )
- return window.outerWidth + window.pageXOffset;
- else
- return document.body.clientWidth + document.body.scrollLeft;
- }
-
- CCSSP.TrimString = function( objString, subtrim )
- {// to trim the "subtrim" in the beginning and ending of a string object
- if( typeof(subtrim) != "string" || subtrim == null )
- return objString;
- var strHead = objString.substring(0, 1);
- var strRear = objString.substring(objString.length-1, objString.length);
- if( strHead != subtrim && strRear != subtrim )
- return objString;
-
- var spacePos = objString.indexOf(subtrim);
- if( spacePos < 0 )
- return objString;
- else if( spacePos == objString.length - 1 )
- return objString.substring(0, spacePos);
- else
- {
- var newString = objString.substring( spacePos + 1, objString.length);
- return CCSSP.TrimString( newString, subtrim );
- }
- }
-
- CCSSP.TrimSpace = function( objString )
- {
- var Trim1 = CCSSP.TrimString( objString, " ");
- return CCSSP.TrimString( Trim1, "\'");
- }
-
- CCSSP.GetEventElement = function( navEventObject )
- {// to get the element who fired the current event
- if( CCSSP.bIsNav4 )
- return navEventObject.target;
- else
- return event.srcElement;
- }
-
- CCSSP.PrepareFilter = function( Obj )
- {//to prepare for making the filter work
- Obj.style.filter = "";
- if( Obj.style.width != "" || Obj.style.height != "" || Obj.style.position == "absolute" )
- return;
- Obj.style.height = CCSSP.GetObjectHeight(Obj);
- }
-
- CCSSP.IsDescendant = function( progenitor, progeny )
- {
- if( typeof(progeny) == "undefined" || progeny == null )
- return false;
- else if( progeny == progenitor )
- return true;
- else if( progeny.id == progenitor.id )
- return true;
- else if( progeny.parentElement == progenitor.parentElement )
- return false;
- else
- return CCSSP.IsDescendant( progenitor, progeny.parentElement );
- }
-
- CCSSP.IsTextTag = function( Obj )
- {
- if( typeof( Obj.tagName ) == "undefined" )
- return false;
- return( Obj.tagName.indexOf("H") == 0 || Obj.tagName == "P" ||
- Obj.tagName == "FONT" || Obj.tagName == "SPAN" );
- }
-
- //End JavaScript libary for cross-platform positioning object.
-
- /// Section End - CCSSP DHTM (JavaScript 1.2)
-
-